package com.gitee.zycra.union.api.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zycra
 */
public enum InterfaceMethodEnum {

    /**
     * 请求类型
     */
    GET(1, "get"),
    POST(2, "post"),
    PUT(3, "put"),
    DELETE(4, "delete"),
    TRACE(5, "trace"),
    HEAD(6, "head"),
    OPTIONS(7, "options");

    private static final Map<Integer, InterfaceMethodEnum> MAP = new HashMap<>();

    static {
        for (InterfaceMethodEnum value : InterfaceMethodEnum.values()) {
            MAP.put(value.getCode(), value);
        }
    }

    /**
     * 枚举值
     */
    private final Integer code;

    /**
     * 枚举描述
     */
    private final String desc;

    InterfaceMethodEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static InterfaceMethodEnum getByCode(Integer code) {
        return MAP.get(code);
    }
}
